var nodemailer = require('nodemailer');

module.exports = {
    post: {
        send: function (req, res) {
            var transporter = nodemailer.createTransport(sysConfig.mail);
            var mailOptions = {
                from: sysConfig.mail.auth.user,
                to: req.form.to,
                subject: req.form.subject,
                html: req.form.html
            };

            transporter.sendMail(mailOptions, function (err, info) {
                if (err) {
                    res.send({
                        err: err,
                        info: null
                    });
                } else {
                    res.send({
                        err: null,
                        info: info
                    });
                }
            });
        }
    }
};